home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Applications / Python 1.3.3 / Python 133 SRC / Mac / mwerks / macuseshlstart.c < prev    next >
C/C++ Source or Header  |  1996-02-20  |  1KB  |  50 lines

  1. /*
  2. ** mac __start for python-with-shared-library.
  3. **
  4. ** Partially stolen from MW Startup.c, which is
  5. **    Copyright © 1993 metrowerks inc. All Rights Reserved.
  6. */
  7.  
  8. #include <setjmp.h>
  9.  
  10. #ifdef PRE_CW8
  11. extern jmp_buf __program_exit;            /*    exit() does a longjmp() to here        */
  12. extern void (*__atexit_hook)(void);        /*    atexit()  sets this up if it is ever called    */
  13. extern void (*___atexit_hook)(void);    /*    _atexit() sets this up if it is ever called    */
  14. extern int __aborting;                    /*    abort() sets this and longjmps to __program_exit    */
  15. #endif
  16.  
  17. /*
  18.  *    clear_stackframe_backlink    -    set 0(SP) to 0
  19.  *
  20.  */
  21.  
  22. static asm void clear_stackframe_backlink(void)
  23. {
  24.         li        r3,0
  25.         stw        r3,0(SP)
  26.         blr
  27. }
  28.  
  29. void __start(void)
  30. {
  31.     char *argv = 0;
  32.     
  33. #ifdef PRE_CW8
  34.     if (setjmp(__program_exit) == 0) {    //    set up jmp_buf for exit()
  35.         main(0, &argv);                //    call main(argc, argv)
  36.         if (__atexit_hook)
  37.             __atexit_hook();            //    call atexit() procs
  38.     }
  39.     if (!__aborting) {
  40.         if (___atexit_hook)
  41.             ___atexit_hook();            //    call _atexit() procs
  42.     }
  43. //    ExitToShell();
  44. #else
  45.     clear_stackframe_backlink();
  46.     main(0, &argv);
  47.     exit(0);
  48. #endif
  49. }
  50.